* data commonly stored in X window properties.
*/
-static GHashTable *names_to_atoms;
-static GPtrArray *atoms_to_names;
-
-static void
-ensure_atom_tables (void)
-{
- if (names_to_atoms)
- return;
-
- names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
- atoms_to_names = g_ptr_array_new ();
-
- g_ptr_array_add (atoms_to_names, NULL);
-}
-
-static GdkAtom
-intern_atom_internal (const gchar *atom_name,
- gboolean allocate)
-{
- gpointer result;
- gchar *name;
-
- ensure_atom_tables ();
-
- if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
- return result;
-
- result = GINT_TO_POINTER (atoms_to_names->len);
- name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
- g_hash_table_insert (names_to_atoms, name, result);
- g_ptr_array_add (atoms_to_names, name);
-
- return result;
-}
-
/**
* gdk_atom_intern:
* @atom_name: a string.
{
g_return_val_if_fail (atom_name != NULL, GDK_NONE);
- return intern_atom_internal (atom_name, TRUE);
+ return g_intern_string (atom_name);
}
/**
{
g_return_val_if_fail (atom_name != NULL, GDK_NONE);
- return intern_atom_internal (atom_name, FALSE);
+ return g_intern_static_string (atom_name);
}
/**
const gchar *
_gdk_atom_name_const (GdkAtom atom)
{
- ensure_atom_tables ();
-
- if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
- return NULL;
-
- return g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom));
+ return atom;
}
* An opaque type representing a string as an index into a table
* of strings on the X server.
*/
-typedef struct _GdkAtom *GdkAtom;
+typedef const char *GdkAtom;
/**
* GDK_ATOM_TO_POINTER:
*
* Converts a #GdkAtom into a pointer type.
*/
-#define GDK_ATOM_TO_POINTER(atom) (atom)
+#define GDK_ATOM_TO_POINTER(atom) ((gpointer) (atom))
/**
* GDK_POINTER_TO_ATOM:
*/
#define GDK_POINTER_TO_ATOM(ptr) ((GdkAtom)(ptr))
-#define _GDK_MAKE_ATOM(val) ((GdkAtom)GUINT_TO_POINTER(val))
-
/**
* GDK_NONE:
*
* A null value for #GdkAtom, used in a similar way as
* `None` in the Xlib API.
*/
-#define GDK_NONE ((GdkAtom) 0)
+#define GDK_NONE NULL
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
info = g_hash_table_lookup (selection->offers, wl_data_offer);
- if (!info || g_list_find (info->targets, atom))
+ if (!info || g_list_find (info->targets, GDK_ATOM_TO_POINTER (atom)))
return;
GDK_NOTE (EVENTS,
g_message ("data offer offer, offer %p, type = %s", wl_data_offer, type));
- info->targets = g_list_prepend (info->targets, atom);
+ info->targets = g_list_prepend (info->targets, GDK_ATOM_TO_POINTER (atom));
}
static inline GdkDragAction
info = g_hash_table_lookup (selection->offers, gtk_offer);
- if (!info || g_list_find (info->targets, atom))
+ if (!info || g_list_find (info->targets, GDK_ATOM_TO_POINTER (atom)))
return;
GDK_NOTE (EVENTS,
g_message ("primary offer offer, offer %p, type = %s", gtk_offer, type));
- info->targets = g_list_prepend (info->targets, atom);
+ info->targets = g_list_prepend (info->targets, GDK_ATOM_TO_POINTER (atom));
}
static const struct gtk_primary_selection_offer_listener primary_offer_listener = {